package main

import (
	"fmt"
	"log"
	"net/http"

	"golang.org/x/sync/errgroup"

	"os"
)

func index(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, "Hello golang http!")
}

func main() {

	var errorGroup errgroup.Group

	interrupt := make(chan os.Signal, 1)
	reload := make(chan os.Signal, 1)

	errorGroup.Go(func() error {

		http.HandleFunc("/", index)

		err := http.ListenAndServe(":10001", nil)
		if err != nil {
			log.Fatal("ListenAndServe:", err)
		}

		return nil

	})

	if httpError := errorGroup.Wait(); httpError == nil {
		http.HandleFunc("/", index)
		http.ListenAndServe(":10002", nil)
	}

}
